// GxOrderEventSink.cpp : implementation file
//

#include "stdafx.h"
#include "SpeedOrder.h"
#include "GxOrderEventSink.h"
#include "wp2_i_5.c"
#include "OrderManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GxOrderEventSink

IMPLEMENT_DYNCREATE(GxOrderEventSink, CCmdTarget)

GxOrderEventSink::GxOrderEventSink()
{
	EnableAutomation();
	m_pOrderMgr = NULL;
}

GxOrderEventSink::~GxOrderEventSink()
{
}


void GxOrderEventSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.
	m_Cookie = 0;
	CCmdTarget::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(GxOrderEventSink, CCmdTarget)
	//{{AFX_MSG_MAP(GxOrderEventSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(GxOrderEventSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(GxOrderEventSink)
	DISP_FUNCTION(GxOrderEventSink, "OnNewOrder", OnNewOrder, VT_EMPTY, VTS_DISPATCH)
	DISP_FUNCTION(GxOrderEventSink, "OnOrderUpdated", OnOrderUpdated, VT_EMPTY, VTS_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IGxOrderEventSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {24C6069A-BBB7-4F20-9C4F-355414EC9DC2}
//static const IID IID_IGxOrderEventSink =
//{ 0x24c6069a, 0xbbb7, 0x4f20, { 0x9c, 0x4f, 0x35, 0x54, 0x14, 0xec, 0x9d, 0xc2 } };

BEGIN_INTERFACE_MAP(GxOrderEventSink, CCmdTarget)
	INTERFACE_PART(GxOrderEventSink, DIID_IGxOrderEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GxOrderEventSink message handlers

void GxOrderEventSink::OnNewOrder(LPDISPATCH a_GxOrder) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnNewOrder(a_GxOrder);
}

void GxOrderEventSink::OnOrderUpdated(LPDISPATCH a_GxOrder) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnOrderUpdated(a_GxOrder);
}
